package com.cryptoneedle.garden.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-02-28
 */
@Data
@Accessors(chain = true)
public class DolphinTaskDefinition {
    
    @Schema(name = "任务ID")
    private Long id;
    @Schema(name = "任务编码")
    private Long code;
    @Schema(name = "任务版本")
    private Integer version;
    @Schema(name = "任务类型")
    private String taskType;
    @Schema(name = "任务执行类型")
    private String taskExecuteType;
    
    @Schema(name = "项目编码")
    private Long projectCode;
    @Schema(name = "项目名称")
    private String projectName;
    @Schema(name = "用户ID")
    private Long userId;
    @Schema(name = "用户名称")
    private String userName;
    @Schema(name = "修改者", description = "ID或名称未知")
    private String modifyBy;
    @Schema(name = "创建时间")
    private Date createTime;
    @Schema(name = "更新时间")
    private Date updateTime;
    @Schema(name = "操作时间")
    private Date operateTime;
    
    /**
     * 作用未知
     */
    
    @Schema(name = "【未知属性】")
    private Integer operator;                   // 4
    @Schema(name = "【未知属性】", description = "常用值：[ ]")
    private List<String> taskParamList;
    @Schema(name = "【未知属性】")
    private String resourceIds;
    
    /**
     * 根据 Seatunnel 组件窗口排序
     */
    
    @Schema(name = "名称")
    private String name;
    @Schema(name = "运行标志")
    private String flag;
    @Schema(name = "缓存执行")
    private String isCache;
    @Schema(name = "描述")
    private String description;
    @Schema(name = "任务优先级")
    private String taskPriority;
    @Schema(name = "Worker分组")
    private String workerGroup;
    @Schema(name = "环境名称")
    private Integer environmentCode;
    @Schema(name = "任务组ID")
    private Long taskGroupId;
    @Schema(name = "组内优先级")
    private Integer taskGroupPriority;
    @Schema(name = "失败重试次数")
    private Integer failRetryTimes;
    @Schema(name = "失败重试间隔")
    private Integer failRetryInterval;
    @Schema(name = "CPU配额")
    private Integer cpuQuota;
    @Schema(name = "最大内存")
    private Integer memoryMax;
    @Schema(name = "延时执行时间")
    private Integer delayTime;
    @Schema(name = "超时告警")
    private String timeoutFlag;
    @Schema(name = "超时策略", description = "未确认字段枚举")
    private String timeoutNotifyStrategy;
    @Schema(name = "超时时长")
    private Integer timeout;
    @Schema(name = "任务参数")
    private TaskParam taskParams;
    
    @Data
    @Accessors(chain = true)
    public static class TaskParam {
        @Schema(name = "启动脚本")
        private String startupScript;
        @Schema(name = "选项参数")
        private String others;
        @Schema(name = "部署方式", description = "cluster | local")
        private String deployMode;
        @Schema(name = "自定义配置")
        private Boolean useCustom;
        @Schema(name = "脚本")
        private String rawScript;
        @Schema(name = "自定义参数")
        private List<LocalParam> localParams;
        @Schema(name = "【未知属性】", description = "常用值：[ ]")
        private List<String> resourceList;
    }
    
    @Schema(name = "自定义参数", description = "同 TaskParam.localParams")
    private List<LocalParam> taskParamMap;
    
    @Data
    @Accessors(chain = true)
    public static class LocalParam {
        @Schema(name = "属性")
        private String prop;
        @Schema(name = "条件")
        private String direct;
        @Schema(name = "数据类型")
        private String type;
        @Schema(name = "值")
        private String value;
    }
}